package cn.edu.just.firstjavaapp.l20;

import javax.swing.*;
import java.awt.*;

public class NestedLayoutDemo {
    public static void main(String[] args) {
        JFrame frame = new JFrame();// Frame的默认布局是BorderLayout
        frame.setBounds(100,100,400,300);

        JButton button1 = new JButton("按钮1");
        frame.add(button1,BorderLayout.NORTH);

        JButton button2 = new JButton("按钮2");
        frame.add(button2,BorderLayout.WEST);

        JPanel centerPanel = new JPanel();  //Panel默认布局是FlowLayout
        centerPanel.setLayout(new BorderLayout());

        JPanel panel1 = new JPanel();
        JPanel panel2 = new JPanel();
        centerPanel.add(panel1,BorderLayout.NORTH);
        centerPanel.add(new JTextArea());
        centerPanel.add(panel2,BorderLayout.SOUTH);

        panel1.add(new JButton("p1btn1"));
        panel1.add(new JButton("p1btn2"));
        panel1.add(new JButton("p1btn3"));

        panel2.add(new JButton("p2btn01"));
        panel2.add(new JButton("p2btn02"));

        frame.add(centerPanel,BorderLayout.CENTER);

        JButton button4 = new JButton("按钮4");
        frame.add(button4,BorderLayout.SOUTH);

        frame.setVisible(true);
    }
}
